home *** CD-ROM | disk | FTP | other *** search
- /*
- There are a couple of fread & fwrite's in h.tex which I'll leave for now.
- (search for 'pending:' in the sources)
-
- itex, extra: changed many fprintf's to os_fputs. Still some complex
- ones to do (eg with %d in them). Also a couple of fputc's
- in the pool reading stuff.
-
- tex0:
- fprintf( stdout ,... only one occurance - changed to Fputs.
-
- tex8:
- fprintf( stdout ,... all recoded as Fputs
- fprintf( logfile ,... left as is - but may change one day if logfile
- goes into a window too...
-
- */
-
- /*
- * Hand-coded routines for C TeX.
- * This module should contain any system-dependent code.
- *
- * This code was written by Tim Morgan, drawing from other Unix
- * ports of TeX.
- */
-
- #ifdef RISC_OS
- int multi_tasking_counter;
- extern int update_pending;
-
- #define POLL() \
- do \
- { \
- if ((multi_tasking_counter = (multi_tasking_counter + 1) % 12) == 0 \
- && text_poll (0) > 0) \
- text_update (); \
- } while(0)
-
- #endif
-
- #ifdef ARTHUR
- #define NEXTSEP ','
- /* NEXTSEP is the character between file-names in an environment string. */
- #define PATHSEP '.'
- /* PATHSEP is the character between nodes in a hierarchical filing system. */
- #define Absolute(tex_name) (0 != 0) /* Too complex to work out properly! */
- /* So we cheat by having an empty item */
- /* as the first item in a path */
- #else
- #define NEXTSEP ':'
- #define PATHSEP '/'
- #define Absolute(tex_name) (*tex_name == '/')
- #endif
-
- #define CATCHINT /* Catch ^C's */
-
- #define EXTERN /* Actually instantiate globals here */
- #include "texd.h"
-
- /* Various include files we'll need */
- #ifdef CATCHINT
- #include <signal.h>
- #endif
- #ifdef BSD
- #include <sys/time.h>
- #include <sys/wait.h>
- #else
- #include <time.h>
- #endif
- #if defined(BSD)||defined(SYSV)
- #include <sgtty.h>
- #endif
-
- static char *texeditvalue = EDITOR;
-
- #ifdef SYSV
- #define index strchr /* Sys V compatibility */
- extern int *sprintf();
- #else
- #ifndef ARTHUR /* Should be in stdio.h */
- extern char *sprintf();
- #endif
- #endif
-
- #ifdef ARTHUR /*ACORN - actually, should be #ifdef __STDC__*/
- #define index strchr
- #endif
-
- /* C library stuff that we're going to use */
- extern char *strcpy(), *strcat(), *malloc(), *index(), *getenv();
-
- /* Local stuff */
- static int gargc;
- static char **gargv;
- static char texformats[filenamesize], texinputs[filenamesize];
- static char texfonts[filenamesize], texpool[filenamesize];
- static char my_realnameoffile[filenamesize];
-
-
- #ifdef RISC_OS_NEVER
- /**************** Yes - but who sets it up??? And it seems a bit weird? */
- #ifdef CATCHINT
- /* If we're catching ^C, come here when one comes in. */
- static catchint()
- {
- interrupt = 1;
- (void) signal(SIGINT, catchint);
- }
- #endif
- #endif
-
- /* Do the obvious */
- get_date_and_time(minutes, day, month, year)
- integer *minutes, *day, *month, *year;
- {
- time_t clock;
- struct tm *tmptr;
-
- clock = time(0);
- tmptr = localtime(&clock);
-
- *minutes = tmptr->tm_hour * 60 + tmptr->tm_min;
- *day = tmptr->tm_mday;
- *month = tmptr->tm_mon + 1;
- *year = tmptr->tm_year + 1900;
- #ifdef RISC_OS_NEVER
- /**************** WHAT THE HELL??? Why do this *here* ????*/
- /* (its not what *I* call obvious.... :-) ) */
- #ifdef CATCHINT
- (void) signal(SIGINT, catchint);
- #endif
- #endif
- }
-
- #ifdef INITEX
- /* Same as in Pascal --- return TRUE if EOF or next char is newline */
- eoln(f)
- FILE *f;
- {
- register int c;
-
- #ifdef RISC_OS
- if (os_feof(f)) return(true);
- c = os_getc(f);
- if (c != EOF)
- (void) os_ungetc(c, f);
- #else
- if (feof(f)) return(true);
- c = getc(f);
- if (c != EOF)
- (void) ungetc(c, f);
- #endif
- return (c == '\n' || c == EOF);
- }
- #endif /* INITEX */
-
- static void copy_path(ptr, defptr, override)
- char *ptr, *defptr, *override;
- {
- if (override) {
- if (strlen(override) >= 1024) {
- #ifdef RISC_OS
- (void) os_fputs("Path too long", stderr);
- uexit(1);
- #else
- (void) fprintf(stderr, "Path too long\n");
- exit(1);
- #endif
- }
- (void) strcpy(ptr, override);
- }
- else
- (void) strcpy(ptr, defptr);
- }
-
-
- /* Initialize path variables for loading fonts and things */
- setpaths()
- {
- copy_path(texformats, TEXFORMATS, getenv("TEXFORMATS"));
- copy_path(texinputs, TEXINPUTS, getenv("TEXINPUTS"));
- copy_path(texfonts, TEXFONTS, getenv("TEXFONTS"));
- copy_path(texpool, TEXPOOL, getenv("TEXPOOL"));
- }
-
- /*
- * The following procedure is due to sjc@s1-c.
- *
- * calledit(filename, fnstart, fnlength, linenumber)
- *
- * TeX82 can call this to implement the 'e' feature in error-recovery
- * mode, invoking a text editor on the erroneous source file.
- *
- * You should pass to "filename" the first character of the packed array
- * containing the filename, and to "fnstart" and "fnlength" the index and
- * length of the filename as it appears inside that array.
- *
- * Ordinarily, this invokes "/usr/ucb/vi". If you want a different
- * editor, create a shell environment variable TEXEDIT containing
- * the string that invokes that editor, with "%s" indicating where
- * the filename goes and "%d" indicating where the decimal
- * linenumber (if any) goes. For example, a TEXEDIT string for a
- * variant copy of "vi" might be:
- *
- * setenv TEXEDIT "/usr/local/bin/vi +%d %s"
- *
- */
-
- calledit(filename, fnstart, fnlength, linenumber)
- ASCIIcode filename[];
- poolpointer fnstart;
- integer fnlength, linenumber;
- {
- char *temp, *command, c;
- int sdone, ddone, i;
-
- sdone = ddone = 0;
- filename += fnstart;
-
- /* Replace default with environment variable if possible.
- * We can get away with a simple assignment because we don't call
- * getenv() again.
- */
- if (NULL != (temp = getenv("TEXEDIT")))
- texeditvalue = temp;
-
- /* Make command string containing envvalue, filename, and linenumber */
- if (NULL ==
- (command = (char *) malloc((unsigned) (strlen(texeditvalue) + fnlength
- + 25)))) {
- #ifdef RISC_OS
- (void)os_fputs("! Not enough memory to issue editor command", stderr);
- uexit(1);
- #else
- (void)fprintf(stderr, "! Not enough memory to issue editor command\n");
- exit(1);
- #endif
- }
- temp = command;
- while ((c = *texeditvalue++) != '\0') {
- if (c == '%') {
- switch (c = *texeditvalue++) {
- case 'd':
- if (ddone) {
- #ifdef RISC_OS
- (void) os_fputs(
- "! Line number cannot appear twice in editor command",
- stderr);
- uexit(1);
- #else
- (void) fprintf(stderr,
- "! Line number cannot appear twice in editor command\n");
- exit(1);
- #endif
- }
- (void) sprintf(temp, "%d", linenumber);
- while (*temp != '\0')
- temp++;
- ddone = 1;
- break;
- case 's':
- if (sdone) {
- #ifdef RISC_OS
- (void) os_fputs(
- "! Filename cannot appear twice in editor command",
- stderr);
- uexit(1);
- #else
- (void) fprintf(stderr,
- "! Filename cannot appear twice in editor command\n");
- exit(1);
- #endif
- }
- i = 0;
- while (i < fnlength)
- *temp++ = filename[i++];
- sdone = 1;
- break;
- case '\0':
- *temp++ = '%';
- texeditvalue--; /* Back up to \0 to force termination. */
- break;
- default:
- *temp++ = '%';
- *temp++ = c;
- break;
- }
- }
- else
- *temp++ = c;
- }
- *temp = '\0';
-
- /* Execute command. */
- #ifdef RISC_OS
- /* Won't work, because needs wimp tasking */
- /*
- if (system(command))
- (void) fprintf(stderr, "! Trouble executing command %s\n", command);
- */
-
- /* Quit, indicating TeX found an error */
- uexit(1);
- #else
- if (system(command))
- (void) fprintf(stderr, "! Trouble executing command %s\n", command);
-
- /* Quit, indicating TeX found an error */
- exit(1);
- #endif
- }
-
-
- /*
- * Change a Pascal-like filename into a C-like string.
- * If running on a non-ASCII system, will have to use xchr[]
- * array to convert from internal character set (in the "nameoffile"
- * array) into the enternal character set (in "realnameoffile").
- * "nameoffile" in TeX is indexed starting at 1, but by the time
- * we're called, it has already been bumped up by one.
- */
- static packrealnameoffile(prefix, nameoffile)
- char *prefix, *nameoffile;
- {
- register char *cp, *p, *q;
-
- p = prefix;
- /* for (q = my_realnameoffile; p && *p && *p != ':'; *q++ = *p++);*/
- for (q = my_realnameoffile; p && *p && *p != NEXTSEP; *q++ = *p++);
- #ifndef ARTHUR /* Arthur pathnames include seperator */
- if (prefix && *prefix)
- *q++ = PATHSEP;
- #endif
- for (cp = nameoffile, p = realnameoffile + 1; *cp != ' ' && *cp;)
- #ifdef NONASCII
- *q++ = xchr[*p++ = *cp++];
- #else
- *q++ = (*p++ = *cp++);
- #endif
- *p = ' ';
- *q = '\0';
- }
-
- #ifdef BSD
- /*
- * This code is from Chris Torek:
- *
- * The following is an internal-use-only routine that makes a core
- * dump without any sort of error status. It is used only when
- * making a production TeX from a virtex, and is triggered by a magic
- * file name requested as \input.
- *
- * This is what is known in computing circles as a hack.
- */
- static void funny_core_dump()
- {
- int pid, w;
- union wait status;
-
- switch (pid = vfork()) {
-
- case -1: /* failed */
- perror("vfork");
- exit(-1);
- /*NOTREACHED*/
-
- case 0: /* child */
- (void) signal(SIGQUIT, SIG_DFL);
- (void) kill(getpid(), SIGQUIT);
- (void) write(2, "how did we get here?\n", 21);
- _exit(1);
- /*NOTREACHED*/
-
- default: /* parent */
- while ((w = wait(&status)) != pid && w != -1)
- ;
- if (status.w_coredump)
- exit(0);
- (void) write(2, "attempt to dump core failed\n", 28);
- exit(1);
- }
- }
- #endif /* BSD */
-
- /* Open an input file f */
- Openin(f, pathspec)
- FILE **f;
- int pathspec;
- {
- register char *prefix, *nprefix;
- register char *cp, *tex_name;
-
- #ifdef BSD
- if (pathspec == inputpathspec &&
- strncmp(nameoffile+1, "HackyInputFileNameForCoreDump.tex", 33) == 0)
- funny_core_dump();
- #endif /* BSD */
- for (tex_name = &nameoffile[1]; *tex_name == ' '; ++tex_name);
-
- switch (pathspec) {
- case inputpathspec:
- case readpathspec:
- prefix = texinputs;
- break;
- case fontpathspec:
- prefix = texfonts;
- break;
- case poolpathspec:
- prefix = texpool;
- break;
- case fmtpathspec:
- prefix = texformats;
- break;
- default: /* "Can't" happen */
- #ifdef RISC_OS
- (void) os_fputs("INTERNAL CONFUSION---IMPLEMENTATION ERROR", stderr);
- uexit(1);
- #else
- (void) fprintf(stderr, "INTERNAL CONFUSION---IMPLEMENTATION ERROR\n");
- exit(1);
- #endif
- }
- /* if (*tex_name == '/') {*/ /* Absolute pathname-don't do path searching */
- if Absolute(tex_name) { /* Absolute pathname-don't do path searching */
- for (cp = tex_name; *cp && *cp != ' '; ++cp);
- *cp = '\0';
- if (*f = fopen(tex_name, "r")) {
- (void) strcpy(realnameoffile + 1, tex_name);
- (void) strcat(realnameoffile + 1, " ");
- if (pathspec == fontpathspec)
- #ifdef RISC_OS
- tfmtemp = os_getc(*f); /* Simulate readahead on TFM files */
- #else
- tfmtemp = getc(*f); /* Simulate readahead on TFM files */
- #endif
- return (1);
- }
- return (0);
- }
- /* Else relative pathname */
- while (prefix) {
- packrealnameoffile(prefix, tex_name);
- *f = fopen(my_realnameoffile, "r");
- if (*f) {
- (void) strcpy(realnameoffile + 1, my_realnameoffile);
- (void) strcat(realnameoffile + 1, " ");
- if (pathspec == fontpathspec)
- #ifdef RISC_OS
- tfmtemp = os_getc(*f); /* Simulate Pascal readahead */
- #else
- tfmtemp = getc(*f); /* Simulate Pascal readahead */
- #endif
- return (1);
- }
- nprefix = index(prefix, NEXTSEP);
- if (nprefix)
- prefix = nprefix + 1;
- else
- break;
- }
- return (0);
- }
-
- /* Open an output file f */
- Openout(f)
- FILE **f;
- {
- register char *tex_name;
-
- for (tex_name = &nameoffile[1]; *tex_name == ' '; ++tex_name);
- packrealnameoffile((char *) NULL, tex_name);
- *f = fopen(my_realnameoffile, "w");
- return (*f != NULL);
- }
-
-
- /*
- * Read a line of input as efficiently as possible while still
- * looking like Pascal.
- * Sets last==first and returns FALSE if eof is hit.
- * Otherwise, TRUE is returned and either last==first or buffer[last-1]!=' ';
- * that is, last == first + length(line except trailing whitespace).
- */
- boolean zinputln(f)
- FILE *f;
- {
- register int i;
-
- last = first;
- #ifdef RISC_OS
- while ( last < bufsize && ((i = os_getc(f)) != EOF) && i != '\n') {
- #else
- while ( last < bufsize && ((i = getc(f)) != EOF) && i != '\n') {
- #endif
- #ifdef NONASCII
- buffer[last++] = i;
- #else
- buffer[last++] = (i > 127 || i < 0)?' ':i;
- #endif
- }
- if (i == EOF && last == first)
- return(false);
- if (i != EOF && i != '\n') {
- /* We didn't get whole line because of lack of buffer space */
- #ifdef RISC_OS
- /* PENDING: DO THIS BY HAND */
- /*
- (void)fprintf(stderr, "\nUnable to read an entire line---bufsize=%d\n",
- bufsize);
- */
- uexit(1);
- #else
- (void) fprintf(stderr, "\nUnable to read an entire line---bufsize=%d\n",
- bufsize);
- exit(1);
- #endif
- }
- buffer[last] = ' ';
- if (last >= maxbufstack)
- maxbufstack = last; /* Record keeping */
- /* Trim trailing whitespace by decrementing "last" */
- while (last > first && (buffer[last-1] == ' ' || buffer[last-1] == '\t'))
- --last;
- /* Now, either last==first or buffer[last-1] != ' ' (or tab) */
- /*
- * If we're running on a system with ASCII characters like TeX's
- * internal character set, we can save some time by not executing
- * this loop.
- */
- #ifdef NONASCII /* BUG: Was *NOT*ASCII ! */
- for (i = first; i <= last; i++)
- buffer[i] = xord[buffer[i]];
- #endif
- return(true);
- }
-
- /*
- * Clear any pending terminal input.
- * The usual way to do this in Unix is to switch the terminal to get
- * the current tty flags, set RAW mode, then switch back to the original
- * setting. If the user isn't in COOKED mode, though, this won't work.
- * At least, it leaves his terminal in its original mode.
- */
- #ifdef RISC_OS
- void text_update(void); /* Used before header file pulled in... :-( */
- #endif
- clearterminal()
- {
- #ifdef BSD
- struct sgttyb sb;
- int flags; /* We save the original flags here */
-
- if (ioctl(fileno(stdout), TIOCGETP, &sb) < 0)
- return; /* Failed for some reason */
- flags = sb.sg_flags;
-
- sb.sg_flags |= RAW;
- if (ioctl(fileno(stdout), TIOCSETP, &sb) < 0)
- return; /* Punt if it fails */
-
- sb.sg_flags = flags;
- (void) ioctl(fileno(stdout), TIOCSETP, &sb);
- #endif /* BSD */
- #ifdef RISC_OS
- #if 0
- if (text_poll(0) >= 0) text_update();
- #else
- POLL ();
- #endif
- /* Would be a little neater if this called wflush() - should
- tidy up w* procs so that they don't take FILE * parameters.
- On the other hand, this would preclude ever having multiple
- windows (eg for the logfile) */
- #endif
- }
-
-
- /*
- * Cancel any output cancellation (^O) by the user. This is 4.2BSD code.
- * Systems which don't have this feature might want to #define wakeupterminal
- * to do nothing, rather than call this empty routine, but it's only called
- * when about to read from the terminal, so the extra time (compared with
- * the human's response time) is minimal.
- */
- wakeupterminal()
- {
- #ifdef BSD
- int i = LFLUSHO;
-
- (void) ioctl(fileno(stdout), TIOCLBIC, (struct sgttyb *) &i);
- #endif /* BSD */
- #ifdef RISC_OS
- /* PENDING: **************** If window not open, do it now!!!!! */
- #if 0
- if (text_poll(0) >= 0) text_update();
- #else
- POLL ();
- #endif
- #endif
- }
-
-
- /*
- * "Open the terminal for input". Actually, copy any command-line
- * arguments for processing. If nothing is available, or we've
- * been called already (and hence, gargc==0), we return with last==first.
- */
- topenin()
- {
- register int i;
-
- if (gargc > 1) {
- buffer[first] = '\0'; /* This makes the first strcat work */
- for (i=1; i<gargc; i++) {
- (void) strcat((char *) &buffer[first], gargv[i]);
- (void) strcat((char *) &buffer[first], " ");
- }
- gargc = 0; /* Don't do this again */
- for (last=first; buffer[last]; ++last);
- for (--last; last >= first && buffer[last] == ' '; --last);
- ++last;
- }
- else last = first; /* This signals that nothing is available */
- }
-
-
- #ifdef sequent
- /*
- * On a Sequent Balance system under Dynix 2.1, if u and v are unsigned
- * shorts or chars, then "(int) u - (int) v" does not perform a signed
- * subtraction. Hence we have to call this routine to force the compiler
- * to treat u and v as ints instead of unsigned ints. Sequent knows about
- * the problem, but they don't seem to be in a hurry to fix it.
- */
- integer ztoint(x)
- {
- return(x);
- }
- #endif
-
- /*
- * Get things going under Unix: set up for rescanning the command line,
- * then call TeX's main body.
- */
-
-
- #ifdef RISC_OS
- #include "text.h"
- /* This section interfaces to the acorn Wimp - it could easily be interfaced
- to any other character-based wimp system, say via curses? */
-
- #define NUM_ROWS 29
- #define NUM_COLS 77
- int max_row = NUM_ROWS;
- int max_col = NUM_COLS;
- int s_row = 0;
- int s_col = 0;
- #endif
-
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- gargc=argc;
- gargv=argv;
- #ifdef RISC_OS
- s_row = 0; s_col = 0;
- if (text_init (max_col, max_row, max_row, "TeX", max_col, max_row, 27) == -1)
- exit (1);
- text_cursor(2, 42);
- #endif
- texbody();
- #ifdef RISC_OS
- /* PENDING: THIS IS PROBABLY A BUG. I expect TeX exits via exit()
- so will never get here. If this is true, set up an exit handler
- to close down the wimp */
- /* In the meantime, I've redeclared uexit(n) to do a text_closedown */
- text_closedown();
- #endif
- }
-
-
- #ifdef DEBUG
- getint()
- {
- int i;
-
- if (fscanf(stdin, "%d", &i)) return(i);
- return(0);
- }
- #endif /* DEBUG */
-
- #ifdef ARTHUR
- /* Since this is used in the dumping/undumping code, going to a file,
- I can safely avoid routing it via the wimp indirections */
- void putw(int w, FILE *f) {
- fputc(w & 255, f); w >>= 8;
- fputc(w & 255, f); w >>= 8;
- fputc(w & 255, f); w >>= 8;
- fputc(w & 255, f);
- }
-
- int getw(FILE *f) {
- int w;
- w = fgetc(f);
- w = w | (fgetc(f)<<8);
- w = w | (fgetc(f)<<16);
- w = w | (fgetc(f)<<24);
- return(w);
- }
- #ifdef RISC_OS /* Running in RISC_OS Windows environment? */
-
- /**************************************************************************/
-
- int wfputc(char c, FILE *f) {
- switch (c) {
- case 8:
- if (s_col > 0) s_col--;
- text_cursor_pos(s_col, s_row);
- break;
- case 7:
- art_vdu(7);
- break;
- case '\n':
- if (s_row == max_row - 1) text_scroll ();
- else s_row++;
- s_col = 0;
- text_cursor_pos(s_col, s_row);
- #if 0
- if (text_poll(0) >= 0) text_update();
- #else
- POLL ();
- #endif
- break;
- case 13:
- s_col = 0;
- text_cursor_pos(s_col, s_row);
- #if 0
- if (text_poll(0) >= 0) text_update();
- #else
- POLL ();
- #endif
- break;
- default:
- if (c < 32) c = '?'; /* %should% report an error, but how? */
- (void)text_putch(c, 0, s_col, s_row);
- s_col = (s_col+1) % max_col;
- if (!s_col) {
- s_row = (s_row+1) % max_row;
- if (s_row == 0) s_row = max_row - 1, text_scroll ();
- }
- text_cursor_pos(s_col, s_row);
- break;
- }
- }
-
- static int os_ch = -1;
- int wgetc(FILE *f) {
- int i;
- if (os_ch != -1) {
- i = os_ch; os_ch = -1;
- return(i);
- }
- while ( (i = text_inkey()) == -1 ) {
- if (i = text_poll(1) >= 0) {
- text_update();
- } else break;
- /* Detect 'close_window' by using text_poll(1)
- and looking at result for -1 */
- }
- if (i == 13) i = '\n';
- if ((i == -1)
- || (i == ('c'&31))
- || (i == 27)) {
- raise(SIGINT);
- } else {
- if ((i == ('d'&31))
- || (i == ('z'&31))) {
- i = -1;
- } else {
- wfputc(i, stderr);
- }
- }
- return (i);
- }
-
- int wungetc(int c, FILE *f) {
- os_ch = c;
- }
-
- int wfputs(char *s, FILE *f) {
- while (*s != '\0') {
- (void) wfputc(*s, f);
- s++;
- }
- (void) wfputc('\n', f);
- #if 0
- text_poll(0); /* Multitask a bit more... */
- #else
- POLL ();
- #endif
- }
-
- int wfput(char *s, FILE *f) {
- while (*s != '\0') {
- (void) wfputc(*s, f);
- s++;
- }
- #if 0
- text_poll(0); /* Multitask a bit more... */
- #else
- POLL ();
- #endif
- }
-
- void wfflush(FILE *f) {
- #if 0
- if (text_poll(0) >= 0) text_update();
- #else
- POLL ();
- #endif
- }
-
- int wfeof(FILE *f) {
- /* Return if escape pressed OR close icon pressed.
- remember that esc should be asynch - so set a flag
- (don't raise a signal as in other progs - TeX doesn't like them */
- #if 0
- if (text_poll(0) >= 0) text_update();
- #else
- POLL ();
- #endif
- return(false);
- }
-
- int wfclose(FILE *f) {
- #if 0
- if (text_poll(0) >= 0) text_update();
- #else
- POLL ();
- #endif
- }
- /**************************************************************************/
-
- void os_readln(FILE *f) {
- if (f == stdin) {
- int c;
- while ((c=wgetc(f))!='\n' && c!=EOF);
- } else {
- int c;
- while ((c=getc(f))!='\n' && c!=EOF);
- }
- }
-
- int os_putc(int c, FILE *f) {
- int i;
- if (f == stderr) {
- i = wfputc(c, f);
- } else {
- i = fputc(c, f);
- }
- #if 0
- text_poll(0); /* Multitask a bit more... */
- #else
- POLL ();
- #endif
- return(i);
- }
-
- void os_fputs(char *s, FILE *stream) {
- if (stream == stderr) {
- (void) wfputs(s, stream);
- } else {
- (void) fputs(s, stream);
- }
- #if 0
- text_poll(0); /* Multitask a bit more... */
- #else
- POLL ();
- #endif
- }
-
- void os_fput(char *s, FILE *stream) {
- if (stream == stderr) {
- (void) wfput(s, stream);
- } else {
- (void) fprintf(stream, "%s", s);
- }
- #if 0
- text_poll(0); /* Multitask a bit more... */
- #else
- POLL ();
- #endif
- }
-
- void os_fflush(FILE *f) {
- if (f == stderr) {
- wfflush(f);
- } else {
- fflush(f);
- }
- #if 0
- text_poll(0); /* Multitask a bit more... */
- #else
- POLL ();
- #endif
- }
-
- int os_feof(FILE *f) {
- if (f == stdin) {
- return(wfeof(f));
- } else {
- return(feof(f));
- }
- }
-
- void os_fclose(FILE *f) {
- if (f == stderr || f == stdin) {
- if (f) (void) wfclose(f);
- } else {
- if (f) (void) fclose(f);
- }
- }
-
- int os_getc(FILE *f) {
- if (f == stdin) {
- return(wgetc(f));
- } else {
- return(getc(f));
- }
- }
-
- int os_ungetc(int c, FILE *f) {
- if (f == stdin) {
- return(wungetc(c, f));
- } else {
- return(ungetc(c, f));
- }
- }
-
- void closemess(void) {
- wfput("\nPress SPACE or click mouse to continue", stderr);
- wfflush(stderr);
- for (;;) {
- int c = wgetc(stdin);
- if (c == ' ') return;
- if (c == 27) return;
- }
- }
-
- #endif
- #endif
-